<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

    <button onclick="handleClick()">按钮1</button>
    <button id="btn2">按钮2</button>
    <button id="btn3">按钮3</button>
    <script>
        //HTML事件
        function handleClick() {
            console.log("按钮1被点击了");
        }
        //DOM0级事件
        var btn = document.getElementById("btn2");
        btn.onclick = function() {
            console.log("按钮2被点击了");
        }

        //DOM2级事件
        var btn3 = document.getElementById("btn3");
        btn3.addEventListener("click", function() {
            console.log("按钮3被点击了");
        });

    </script>
</body>
</html>